<template>
  <div class="task-course-swiper-com">
    <div class="vant-swip">
      <van-swipe :autoplay="3000" :show-indicators="false" @change="changeIndex">
        <van-swipe-item v-for="(item, index) in swiperArr" :key="'sw' + index">
          <img :src="item.imgUrl" @click="tap2url(item.jumpUri)" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="indicator" v-if="swiperArr.length>1">
      <div class="indicator-text">
        {{current + 1}}&nbsp;
        <span>/</span>
        &nbsp;{{swiperArr.length}}
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
import mixin from "../utils/mixin";
import { Swipe, SwipeItem, Toast } from 'vant'
Vue.use(Swipe).use(SwipeItem)

export default {
  name: "taskCourseSwiper",
  mixins: [mixin],
  data () {
    return {
      current: 0,
      swiperArr: []
    };
  },
  props: {
    swiperData: Array
  },
  watch: {
    swiperData (newVal) {
      this.swiperArr = newVal
    }
  },
  methods: {
    changeIndex(index) {
      this.current = index
    },
    tap2url (url) {
      window.location.href = url
    }
  },
  components: {}
};
</script>

<style scoped lang="scss">
@import '~@/assets/css/common.scss';
.task-course-swiper-com {
  position: relative;
  height: 300px;
  width: 686px;
  background: transparent;
  border-radius: 16px;
  overflow: hidden;
  .vant-swip {
    img {
      display: block;
      height: 300px;
      width: 686px;
      border-radius: 16px;
    }
  }
  .indicator {
    width: 70px;
    height: 34px;
    background: url('../assets/images/home_banner_pages.png') center / contain
      no-repeat;
    position: absolute;
    left: 16px;
    bottom: 17px;
    line-height: 34px;
    text-align: center;
    .indicator-text {
      height: 34px;
      font-size: 20px;
      font-family: PingFangSC-Medium;
      font-weight: 500;
      color: rgba(255, 255, 255, 1);
      line-height: 34px;
      span {
        height: 34px;
        font-size: 12px;
        font-family: PingFangSC-Regular;
        font-weight: 400;
        color: rgba(255, 255, 255, 1);
        line-height: 34px;
      }
    }
  }
}
</style>
